package kuaidi.view.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by John on 2016/10/5.
 */

public class MainFragmentAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> data;
    private String[] names;

    public MainFragmentAdapter(FragmentManager fm, List<Fragment> data, String[] names) {
        super(fm);
        this.data = data;
        this.names = names;
    }

    @Override
    public int getCount() {
        return data!=null?data.size():0;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return names[position];
    }
}

